package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/9/7.
 */
@HttpInlet(Conn.USERINFO_GET)
public class MinePersonalInfoGet extends BaseAsyGet<MinePersonalInfoGet.PersonalInfoEntity> {

    public String user_id;

    public MinePersonalInfoGet(AsyCallBack<PersonalInfoEntity> asyCallBack) {
        super(asyCallBack);
    }


    @Override
    protected PersonalInfoEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            JSONObject infoObject = object.optJSONObject("data");

            PersonalInfoEntity personalInfoEntity = new PersonalInfoEntity();

            personalInfoEntity.user_id = infoObject.optString("user_id");
            personalInfoEntity.nickname = infoObject.optString("nickname");
            personalInfoEntity.truename = infoObject.optString("truename");
            personalInfoEntity.avatar = Conn.BASE_URL + infoObject.optString("avatar");
            personalInfoEntity.integral = infoObject.optString("integral");
            personalInfoEntity.coupon = infoObject.optString("coupon");
            personalInfoEntity.wallet = infoObject.optString("wallet");
            personalInfoEntity.privilege = infoObject.optString("privilege");
            personalInfoEntity.privilege_endtime = infoObject.optString("privilege_endtime");

            return personalInfoEntity;

        }

        return null;
    }

    public class PersonalInfoEntity {

        public String user_id, nickname, truename, avatar, integral, coupon, wallet, privilege, privilege_endtime;

    }
}
